package fr.vvins.core.page.entity;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.Basic;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MapKeyColumn;
import javax.persistence.Table;

import fr.vvins.core.dao.EntityImpl;

@Entity
@Table(schema="www", name="WWW_BLOCK")
public class Block extends EntityImpl implements Serializable {
	
	private static final long serialVersionUID = 2375350975022071427L;

	@Id
	@Column(name="ID")
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;
	
	@Basic
	@Column(name="URL")
	private String url;

	@Basic
	@Column(name="TARGET")
	private String targetPage;

	@Basic
	@Column(name="MAX_ELEMENT")
	private Integer limit;
	
	@Basic
	@Column(name="SORT")
	private String sort;
	
	@ManyToOne
	@JoinColumn(name="TPL_ID")
	private Template template;
	
	@ElementCollection
	@CollectionTable(schema="www", name="WWW_BLOCK_PARAM",
	        joinColumns=@JoinColumn(name="BLOCK_ID"))
	@MapKeyColumn(name="KEY")
	@Column(name="VALUE")
	private Map<String,String> params = new HashMap<String,String>();
		

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Integer getLimit() {
		return limit;
	}

	public void setLimit(Integer limit) {
		this.limit = limit;
	}

	public String getTargetPage() {
		return targetPage;
	}

	public void setTargetPage(String targetPage) {
		this.targetPage = targetPage;
	}

	public Map<String, String> getParams() {
		return params;
	}

	public void setParams(HashMap<String, String> params) {
		this.params = params;
	}

	public void setParams(Map<String, String> params) {
		this.params = params;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public Template getTemplate() {
		return template;
	}

	public void setTemplate(Template template) {
		this.template = template;
	}

}
